package com.kedacom.ctsp.authz.security.captcha;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 验证码配置类
 *
 * @author sunchenjie
 * @create 2017-12-28 14:50
 **/
@Configuration
@EnableConfigurationProperties(CaptchaProperties.class)
public class CaptchaConfiguration {

    @Bean
    @ConditionalOnProperty(prefix = "commons.authz.captcha", value = "enable")
    @ConditionalOnMissingBean(CaptchaService.class)
    public CaptchaService createCaptcha(CaptchaProperties captchaProperties) {
        return new KaptchaService(captchaProperties);
    }
}